

package com.licw.zs.s397;

class p2 {
    public static void main(String[] args) {
        Solution solution = new Solution();
    }

    static
//leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int maximumEnergy(int[] energy, int k) {
            int n = energy.length, ans = 0;
            for (int i = 0; i < k; i++) {
                int sum = energy[n - 1 - i];
                for (int j = n - 1 - i - k; j >= 0; j-=k) {
                    sum += energy[j];
                    ans = Math.max(ans, sum);
                }
            }
            return ans;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}